#include "AboutScene.h"
#include "MenuScene.h"

using namespace cocos2d::ui;


AboutScene::AboutScene()
{
}

AboutScene::~AboutScene()
{
}

CCScene* AboutScene::scene()
{
	CCScene* scene = CCScene::create();
	CCLayer* layer = AboutScene::create();
	scene->addChild(layer);
	return scene;
}

bool AboutScene::init()
{
	if (!CCLayer::init())
	{
		return false;
	}

	ui::Widget* widge = GUIReader::shareReader()->widgetFromJsonFile("About.json");
	ActionManager::shareManager()->playActionByName("About.json", "aboutAnimation");
	UILayer* ui = UILayer::create();
	ui->addWidget(widge);
	this->addChild(ui); 

	ui::Button* button = dynamic_cast<ui::Button*>(ui::UIHelper::seekWidgetByName(widge, "back"));
	if (button)
	{
		button->addTouchEventListener(this, toucheventselector(AboutScene::backButtonCallBack));
	}
	return true;
}

void AboutScene::backButtonCallBack(CCObject* obj, ui::TouchEventType type)
{
	CCScene* pScene = MenuScene::scene();
	CCDirector::sharedDirector()->replaceScene(pScene);
}